
# F000 TOP Things
TOP_STUDY = 0X1
TOP_SLEEP = 0X2
TOP_EXERCISE = 0X3
TOP_MISC = 0X4
TOP_RELAX = 0X5

# 0F00 Second Things
SEC_OTHERS = 0XF
# 1F00 Study
SEC_DIARY = 0X1
SEC_SELF_AFTERCLASS = 0X2
SEC_SELF_INCLASS = 0X3
SEC_INCLASS = 0X4
# 2F00 Sleep
SEC_NIGHT = 0X1
SEC_NOON = 0X2
SEC_DINNER = 0X3
# 3F00 Exercise
SEC_RUNNING = 0X1
SEC_ABDOMINAL = 0X2
# 4F00 MISC
SEC_WASH = 0X1
SEC_EAT = 0X2
SEC_CHAT = 0X3
# 5F00 Relax
SEC_PHONE_COMMON = 0X1
SEC_PHONE_BEFORESLEEP = 0X2
SEC_PHONE_AFTERSLEEP = 0X3
SEC_COMPUTER = 0X4
SEC_FRIENDS = 0X5
SEC_T = 0X6

# 00F0 Attribute
ATTR_LEGAL = 0X8
ATTR_EFFICIENT = 0X4


# 000F Reserved


def analyzeAttribute(ui):
    attr = 0

    # study
    if ui.studyOthers.isChecked():
        attr = (TOP_STUDY << 4) + SEC_OTHERS
    elif ui.studyDiary.isChecked():
        attr = (TOP_STUDY << 4) + SEC_DIARY
    elif ui.studySelfAfterClass.isChecked():
        attr = (TOP_STUDY << 4) + SEC_SELF_AFTERCLASS
    elif ui.studySelfInClass.isChecked():
        attr = (TOP_STUDY << 4) + SEC_SELF_INCLASS
    elif ui.studyInClass.isChecked():
        attr = (TOP_STUDY << 4) + SEC_INCLASS

    # sleep
    elif ui.sleepOthers.isChecked():
        attr = (TOP_SLEEP << 4) + SEC_OTHERS
    elif ui.sleepNight.isChecked():
        attr = (TOP_SLEEP << 4) + SEC_NIGHT
    elif ui.sleepNoon.isChecked():
        attr = (TOP_SLEEP << 4) + SEC_NOON
    elif ui.sleepDinner.isChecked():
        attr = (TOP_SLEEP << 4) + SEC_DINNER

    # Exercise
    elif ui.exerciseOthers.isChecked():
        attr = (TOP_EXERCISE << 4) + SEC_OTHERS
    elif ui.exerciseRunning.isChecked():
        attr = (TOP_EXERCISE << 4) + SEC_RUNNING
    elif ui.exerciseAbdominal.isChecked():
        attr = (TOP_EXERCISE << 4) + SEC_ABDOMINAL

    # Misc
    elif ui.miscOthers.isChecked():
        attr = (TOP_MISC << 4) + SEC_OTHERS
    elif ui.miscWash.isChecked():
        attr = (TOP_MISC << 4) + SEC_WASH
    elif ui.miscEat.isChecked():
        attr = (TOP_MISC << 4) + SEC_EAT
    elif ui.miscChat.isChecked():
        attr = (TOP_MISC << 4) + SEC_CHAT

    # Relax
    elif ui.relaxOthers.isChecked():
        attr = (TOP_RELAX << 4) + SEC_OTHERS
    elif ui.relaxPhoneCommon.isChecked():
        attr = (TOP_RELAX << 4) + SEC_PHONE_COMMON
    elif ui.relaxPhoneBeforeSleep.isChecked():
        attr = (TOP_RELAX << 4) + SEC_PHONE_BEFORESLEEP
    elif ui.relaxPhoneAfterSleep.isChecked():
        attr = (TOP_RELAX << 4) + SEC_PHONE_AFTERSLEEP
    elif ui.relaxComputer.isChecked():
        attr = (TOP_RELAX << 4) + SEC_COMPUTER
    elif ui.relaxFriends.isChecked():
        attr = (TOP_RELAX << 4) + SEC_FRIENDS
    elif ui.relaxT.isChecked():
        attr = (TOP_RELAX << 4) + SEC_T

    attr = attr << 4
    # attribute
    if ui.checkBoxEfficient.isChecked():
        attr += ATTR_EFFICIENT
    if ui.checkBoxLegal.isChecked():
        attr += ATTR_LEGAL

    attr = attr << 4
    return attr
